#include <stdio.h>
#include <stdlib.h>

typedef char DataType; //假设结点的数据域类型是字符
typedef struct node { //结点类型定义
    DataType data; //结点的数据域
    struct node *next;//结点的指针域
} StackNode;
typedef StackNode *LinkStack;


////置空栈
void InitStack(LinkStack top)
{
    top = NULL;
}

//判栈空
int StackEmpty(LinkStack top)
{
    return top == NULL;
}

//进栈
LinkStack Push(LinkStack top, DataType x)
{
    StackNode *p;
    p = (StackNode *)malloc(sizeof(StackNode));
    p->data = x; // 数据域赋值 x
    p->next = top;//指针域指向栈顶

    top = p;//栈顶指向新结点
    return top;
}

//退栈
LinkStack Pop(LinkStack top, DataType *x)
{
    StackNode *p=top;

    if(StackEmpty(top)){
        printf("stack is empty");
        exit(0);
    }else{
        *x = p->data;
        top = p->next;
        free(p);
        return top;
    }
}

//取栈顶元素
DataType GetPop(LinkStack top)
{
    if(StackEmpty(top)){
        printf("stack is empty");
        exit(0);
    }
    else{
        return top->data;
    }
}

int main()
{
	LinkStack top=NULL;
	DataType ch,x;
	InitStack(top);
	printf("%d", StackEmpty(top));
	
	ch = getchar();
	while(ch!='\n'){
		top = Push(top, ch);
		ch=getchar();
	}
	
	while(!StackEmpty(top)){
		top=Pop(top, &x);
		putchar(x);
	}
	
    return 0;
}